package com.cindata

import com.cindata.dictionary.WarrantType

class Warrant
{

    String serialNumber
    // 权利证明编号

    WarrantType type
    // 权利证明类型

    String name
    // 权利证明名称

    Contract contract
    // 关联担保合同  

    BigDecimal amount
    // 权利金额

    Account account
    // 抵押登记机关

    Date registerDate
    // 抵押登记日期

    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User createBy
    User modifyBy

    static belongsTo = [collateral: Collateral]

    static constraints = {
        createdDate nullable: true, blank: true
        modifiedDate nullable: true, blank: true
        createBy nullable: true, blank: true
        modifyBy nullable: true, blank: true

        collateral nullable: true, blank: true
        contract nullable: true, blank: true
        account nullable: true, blank: true
    }

    static mapping = {}
    def springSecurityService

    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        createBy = User.findByUsername(username)
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }
}